<?php
/******************************************************
v4 - Management Framework
Copyright (C) 2008  Gary Taylor, gMerc Incorporation
http://www.gmerc.com/v4/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

gary@gmerc.com
******************************************************/
class index {
  function loaddata() {
    global $masterclass;

    $masterclass->loadmodule('customers');
    $masterclass->loadmodule('personnel');
    $masterclass->loadmodule('invoices');

    $masterclass->loadjavascript('invoices');

    $masterclass->websiteconfig['javascript_include'][]='include/date-picker-alt.js';
    
    $masterclass->loadjavascript('',$masterclass->mainconfig['v4rootdir'].'include/suckertreemenu.inc.js');

    $masterclass->websiteconfig['title'].=' - '.$masterclass->allclasses['personnel']->fetch_personnelname($masterclass->site['personnelid']);
  return;
  }
  
  function savedata() {
    global $masterclass;
    
    foreach ($masterclass->sitevars['post_action'] as $postaction) {
      switch ($postaction) {
       case '':
       
      break;
      }
    }
     
  return;
  }
  function invoices_removeinvoice() {
    global $masterclass;

    if (isset($_POST['rsargs'])) {
      $masterclass->sitevars['invoicesid']=$_POST['rsargs'][1];
    }
    $dbinfo = array(
      'table'=>'invoices_documents',
      'trackingid'=>'invoicesid',
      'static'=>array('active'=>'0')
    );
    $masterclass->uploaddata($dbinfo);
  return;
  }
  function invoices_savepayment() {
    global $masterclass;

    $invoiceid=$_POST['rsargs'][1];
    $paymentdate=$_POST['rsargs'][2];

    $masterclass->sitevars['invoicesid']=$invoiceid;

    $dbinfo = array(
      'table'=>'invoices_documents',
      'trackingid'=>'invoicesid',
      'static'=>array($paymentdate=>'paid')
    );
    $masterclass->uploaddata($dbinfo);

  return;
  }
  function display_customerlist($containername='',$listview='',$pg='') {
    global $masterclass;

    if (isset($_POST['rsargs']) && !empty($_POST['rsargs'])) {
      $containername=$_POST['rsargs'][1];
      $listview=$_POST['rsargs'][2];
      $pg=$_POST['rsargs'][3];
    }

    if ($pg<0) { $pg=1; }

    switch ($listview) {
     default:
     case 'all':
      $strwhere=" (`active`='1') ";
      $headline='All Customers';
    break;
    }

    $listcnt=$masterclass->fetch_recordcount('customers',$strwhere);
    $listpgcount=ceil($listcnt/$masterclass->websiteconfig['entriesperpage']);
    $listarray=$masterclass->fetch_records('`customers`',$pg,$strwhere,' `updated` DESC, `first`,`last` ');

    $ret='';
    $ret.='<div class="sitebox_navigation" style="text-align:center;font-weight:800;border-bottom:1px solid;"><b>'.$headline.'</b></div>';
    $ret.='<table width="100%" align="center" cellpadding="0" cellspacing="0" class="sitebox_content">';
    if (!$listarray) {
      $ret.='<tr valign="top">';
      $ret.='<td width="100%" valign="middle" style="padding-left:2px;text-align:center;">No Customers</td>';
      $ret.='</tr>';
    } else {
      while (!$listarray->EOF) {

        $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/customers_invoice.php?customerid='.$listarray->fields['id'].'\',\'customers_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';
        $newopenclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/quote.php?customerid='.$listarray->fields['id'].'\',\'_blank\',\'760\',\'600\');"  ';
        $onmouseover=' OnMouseOver="this.className=\'sitebox_content_mouseover\';" OnMouseOut="this.className=\'sitebox_content\';" ';

        $trclass=' class="sitebox_content" ';
        $tdclass=' class="sitebox_content" ';
        $ret.='<tr valign="top" '.$trclass.' '.$onmouseover.' style="cursor:pointer;">';

        $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0"alt="Open" title=" Open"></td>';
        $ret.='<td '.$newopenclick.' width="20" valign="middle" style="padding-left:2px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/report_edit.png" border="0" alt="New Invoice" title=" New Invoice ">&nbsp;</td>';

        $ret.='<td '.$openclick.' '.$tdclass.' valign="middle" style="padding-left:2px;text-align:left;border-bottom:1px solid;"><nobr>'.$listarray->fields['first'].' '.$listarray->fields['last'].'</nobr>&nbsp;</td>';
        $ret.='<td '.$openclick.' '.$tdclass.' width="50" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>'.date("m-d-Y",strtotime($listarray->fields['updated'])).'</nobr>&nbsp;</td>';
        $ret.='</tr>';
        
      $listarray->MoveNext();
      }
    }
    $ret.='</table>';

    $arrret=array(
    'load_list'=>$ret,
    'load_listpage'=>$pg,
    'load_listpagecnt'=>$listpgcount,
    'load_listcnt'=>$listcnt,
    'load_containername'=>$containername
    );

    $masterclass->site['grabdata_vars']['load_list']=$ret;
    $masterclass->site['grabdata_vars']['load_listpage']=$pg;
    $masterclass->site['grabdata_vars']['load_listpagecnt']=$listpgcount;
    $masterclass->site['grabdata_vars']['load_listcnt']=$listcnt;
    $masterclass->site['grabdata_vars']['load_containername']=$containername;

  return $arrret;
  }
  function display_invoices($containername='',$listview='',$pg='') {
    global $masterclass;

    if (isset($_POST['rsargs']) && !empty($_POST['rsargs'])) {
      $containername=$_POST['rsargs'][1];
      $listview=$_POST['rsargs'][2];
      $pg=$_POST['rsargs'][3];
    }

    if ($pg<0) { $pg=1; }

    switch ($listview) {
     default:
      $strwhere=" (`active`='1') ";
      $strorderby=' ABS(`documentid`) DESC, `documentdate` DESC, `updated` DESC ';
     break;
    }
    $listcnt=$masterclass->fetch_recordcount('invoices_documents',$strwhere);
    $listpgcount=ceil($listcnt/$masterclass->websiteconfig['entriesperpage']);
    $listarray=$masterclass->fetch_records('`invoices_documents`',$pg,$strwhere,$strorderby);

    $ret='';

    $ret.='<table width="100%" align="center" cellpadding="0" cellspacing="0" class="sitebox_content">';
    if (empty($listarray)) {
      $ret.='<tr valign="top">';
      $ret.='<td width="100%" valign="middle" style="padding-left:2px;text-align:center;">No Invoices</td>';
      $ret.='</tr>';
    } else {
      while (!$listarray->EOF) {
          
        $csstype=$listarray->fields['documenttype'];
        if ($listarray->fields['paid']=='0000-00-00' || $listarray->fields['paid']=='') { $csstype='unpaid'; }
        $invoicetotals=$masterclass->allclasses['invoices']->calc_invoicetotal($masterclass->allclasses['invoices']->fetch_invoices_items($listarray->fields['id']));
  
        $onmouseover=' OnMouseOver="this.className=\'sitebox_content_mouseover\';" OnMouseOut="this.className=\'sitebox_invoiceslist_'.$csstype.'\';" ';

        $trclass=' class="sitebox_invoiceslist_'.$csstype.'" ';
        $tdclass=' class="sitebox_invoiceslist_'.$csstype.'" ';
        
        $removeitemclick='OnClick="if (confirm(\'Remove Invoice\\nInvoice #'.$listarray->fields['documentid'].'?\')) { invoices_remove_invoice(\'invoices_removeinvoice\',\''.$listarray->fields['id'].'\'); }" ';

        $ret.='<tr valign="top" '.$trclass.' '.$onmouseover.' style="cursor:pointer;">';

        if (strtolower($listarray->fields['documenttype'])=='invoice') {
          $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';
          $emailinvoiceclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice_emailpdf.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_emailpdf'.$listarray->fields['id'].'\',\'540\',\'360\');" ';
          $pdfclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice_pdf.php?nohtml=1&invoicesid='.$listarray->fields['id'].'\',\'invoices_pdf'.$listarray->fields['id'].'\',\'540\',\'360\');" ';

          $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0" alt="Open" title=" Open "></td>';
          $ret.='<td '.$pdfclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/page_white_acrobat.png" border="0"  alt="Open PDF" title=" Open PDF "></td>';
          $ret.='<td '.$emailinvoiceclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/email_go.png" border="0" alt="E-Mail" title=" E-Mail "></td>';
          //$ret.='<td '.$paymentinvoiceclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/money_dollar.png" border="0" alt="'.$paymenttitle.'" title=" '.$paymenttitle.' "></td>';
          $ret.='<td '.$removeitemclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/cross.png" border="0" alt="Delete" title=" Delete "></td>';

        } else {
          $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/quote.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';

          $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0" alt="Open" title=" Open "></td>';
          $ret.='<td '.$openclick.' colspan="2" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;">'.substr(strtoupper($listarray->fields['documenttype']),0,4).'&nbsp;</td>';
          $ret.='<td '.$removeitemclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/cross.png" border="0" alt="Delete" title=" Delete "></td>';
        }
            

        $ret.='<td '.$openclick.' '.$tdclass.' width="15" valign="middle" style="padding-left:5px;text-align:left;border-bottom:1px solid;"><nobr>#'.$listarray->fields['documentid'].'</nobr>&nbsp;&nbsp;</td>';
        $ret.='<td '.$openclick.' '.$tdclass.' valign="middle" style="padding-left:5px;text-align:left;border-bottom:1px solid;"><nobr>'.$listarray->fields['recipientlineone'].'</nobr>&nbsp;&nbsp;</td>';
        if ($listarray->fields['customer']!='' && $listarray->fields['customer']!=0) {
          $opencustomerclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/quote.php?customerid='.$listarray->fields['id'].'\',\'_blank\',\'760\',\'600\');"  ';
          $customername=$masterclass->allclasses['customers']->fetch_customername($listarray->fields['customer']);
        } else {
          $opencustomerclick='';
          $customername='&nbsp;';
        }
        //$ret.='<td '.$opencustomerclick.' '.$tdclass.' width="25" valign="middle" style="padding-left:2px;text-align:left;border-bottom:1px solid;"><nobr>'.$customername.'</nobr>&nbsp;&nbsp;</td>';
        
        $ret.='<td '.$openclick.' '.$tdclass.' width="50" valign="middle" style="padding-left:5px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>'.date("m-d-Y",strtotime($listarray->fields['documentdate'])).'</nobr>&nbsp;</td>';
        $ret.='<td '.$openclick.' '.$tdclass.' width="50" valign="middle" style="padding-left:5px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>'.date("m-d-Y",strtotime($listarray->fields['duedate'])).'</nobr>&nbsp;</td>';
        $ret.='<td '.$openclick.' '.$tdclass.' width="75" valign="middle" style="padding-left:5px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>$'.number_format($invoicetotals['total'],2).'</nobr>&nbsp;&nbsp;</td>';
        $ret.='</tr>';
        
      $listarray->MoveNext();
      }
    }
    $ret.='</table>';
    
    $arrret=array(
    'load_list'=>$ret,
    'load_listpage'=>$pg,
    'load_listpagecnt'=>$listpgcount,
    'load_listcnt'=>$listcnt,
    'load_containername'=>$containername
    );

    $masterclass->site['grabdata_vars']['load_list']=$ret;
    $masterclass->site['grabdata_vars']['load_listpage']=$pg;
    $masterclass->site['grabdata_vars']['load_listpagecnt']=$listpgcount;
    $masterclass->site['grabdata_vars']['load_listcnt']=$listcnt;
    $masterclass->site['grabdata_vars']['load_containername']=$containername;

  return $arrret;
  }
  function display_invoicesdue($containername='',$listview='',$pg='') {
    global $masterclass;

    if (isset($_POST['rsargs']) && !empty($_POST['rsargs'])) {
      $containername=$_POST['rsargs'][1];
      $listview=$_POST['rsargs'][2];
      $pg=$_POST['rsargs'][3];
    }

    if ($pg<0) { $pg=1; }

    switch ($listview) {
     default:
      if ($strwhere!='') { $strwhere.=' AND '; }
      $strwhere.=" (`active`='1') AND (`duedate`='".date("Y-m-d")."'  AND `paid`='0000-00-00') AND (`documenttype`='invoice') ";
      $strorderby=' ABS(`documentid`) DESC, `documentdate` DESC, `updated` DESC ';
     break;
     case 'overdue':
      if ($strwhere!='') { $strwhere.=' AND '; }
      $strwhere.=" (`active`='1') AND (`duedate`<'".date("Y-m-d")."' AND `paid`='0000-00-00') AND (`documenttype`='invoice') ";
      $strorderby=' `duedate` DESC ';
     break;
    }
    $listcnt=$masterclass->fetch_recordcount('invoices_documents',$strwhere);
    $listpgcount=ceil($listcnt/$masterclass->websiteconfig['entriesperpage']);
    $listarray=$masterclass->fetch_records('`invoices_documents`',$pg,$strwhere,$strorderby);

    $ret='';

    $ret.='<table width="100%" align="center" cellpadding="0" cellspacing="0" class="sitebox_content">';
    if (empty($listarray)) {
      $ret.='<tr valign="top">';
      $ret.='<td width="100%" valign="middle" style="padding-left:2px;text-align:center;">No Invoices</td>';
      $ret.='</tr>';
    } else {
      while (!$listarray->EOF) {
        $invoicetotals=$masterclass->allclasses['invoices']->calc_invoicetotal($masterclass->allclasses['invoices']->fetch_invoices_items($listarray->fields['id']));
        
        $trclass=' class="sitebox_invoiceslist_'.$csstype.'" ';
        $tdclass=' class="sitebox_invoiceslist_'.$csstype.'" ';
        
        $onmouseover=' OnMouseOver="this.className=\'sitebox_content_mouseover\';" OnMouseOut="this.className=\'sitebox_content\';" ';
        
        $ret.='<tr valign="top" '.$trclass.' '.$onmouseover.' style="cursor:pointer;">';
        
        if (strtolower($listarray->fields['documenttype'])=='invoice') {
          $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';
          $emailinvoiceclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice_emailpdf.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_emailpdf'.$listarray->fields['id'].'\',\'540\',\'360\');" ';
          $pdfclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice_pdf.php?nohtml=1&invoicesid='.$listarray->fields['id'].'\',\'invoices_pdf'.$listarray->fields['id'].'\',\'540\',\'360\');" ';

          $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0" alt="Open" title=" Open "></td>';
          $ret.='<td '.$pdfclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/page_white_acrobat.png" border="0"  alt="Open PDF" title=" Open PDF "></td>';
          $ret.='<td '.$emailinvoiceclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/email_go.png" border="0" alt="E-Mail" title=" E-Mail "></td>';

        } else {
          $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/quote.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';

          $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0" alt="Open" title=" Open "></td>';
          $ret.='<td colspan="2" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;">&nbsp;</td>';
       }
        
        $ret.='<td '.$openclick.' '.$tdclass.' valign="middle" style="padding-left:5px;text-align:left;border-bottom:1px solid;"><nobr>#'.$listarray->fields['documentid'].'&nbsp;'.$listarray->fields['recipientlineone'].'</nobr>&nbsp;&nbsp;</td>';
        $ret.='<td '.$openclick.' '.$tdclass.' width="75" valign="middle" style="padding-left:5px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>$'.money_format("%i",$invoicetotals['total']).'</nobr>&nbsp;&nbsp;</td>';
        $ret.='</tr>';
        
      $listarray->MoveNext();
      }
    }
    $ret.='</table>';
    
    $arrret=array(
    'load_list'=>$ret,
    'load_listpage'=>$pg,
    'load_listpagecnt'=>$listpgcount,
    'load_listcnt'=>$listcnt,
    'load_containername'=>$containername
    );

    $masterclass->site['grabdata_vars']['load_list']=$ret;
    $masterclass->site['grabdata_vars']['load_listpage']=$pg;
    $masterclass->site['grabdata_vars']['load_listpagecnt']=$listpgcount;
    $masterclass->site['grabdata_vars']['load_listcnt']=$listcnt;
    $masterclass->site['grabdata_vars']['load_containername']=$containername;

  return $arrret;
  }

  function display() {
  global $masterclass;
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top">
    <td>
<?php
  $pageheader='<table width="100%" cellpadding="0" cellspacing="0" border="0" class="sitebox_pageheader"><tr>';
  $pageheader.='<td style="text-align:left;">'.$masterclass->websiteconfig['title'].'</td>';
  $pageheader.='<td style="text-align:right;" width="25">';
  /*$pageheader.='<div style="font-size:8pt;"><nobr>'.$masterclass->allclasses['personnel']->fetch_personnelname($masterclass->site['personnelid']).' ['.$masterclass->site['personnelid'].']</nobr></div><div style="font-size:8pt;"><nobr>'.$_SERVER['REMOTE_ADDR'].'</nobr></div>';*/
  /*$pageheader.='<input type="button" class="button" value=" Logout " OnClick="window.location=\''.$masterclass->mainconfig['dir'].'logout.php\'">';*/
  $pageheader.='</td>';
  $pageheader.='</tr></table>';
  echo $masterclass->allclasses['websites']->sitebox_pageheader($pageheader,'');
?>
  </td>
  </tr>
</table>
<?php
$nav='';
$nav.='<div class="sitebox_navigation" style="width:100%;">';
$nav.='<ul id="sitebox_navmenu">';
$nav.='<li><a>New</a>';
$nav.='<ul>';
$nav.='<li style="border-top:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/customers_invoice.php\',\'_blank\',\'760\',\'480\');"><a>New Customer</a></li>';
$nav.='<li OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/quote.php\',\'_blank\',\'760\',\'480\');"><a>New Invoice</a></li>';
$nav.='<li style="border-bottom:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/makepayment.php\',\'_blank\',\'760\',\'480\');"><a>New Payment</a></li>';
$nav.='</ul>';
$nav.='</li>';
$nav.='<li><a>Reports</a>';
$nav.='<ul>';
$nav.='<li style="border-top:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/report.php?report=totals\',\'_blank\',\'760\',\'480\');"><a>Totals</a></li>';
$nav.='<li OnClick="openwindow(\'invoices/report.php?report=customers\',\'_blank\',\'760\',\'480\');"><a>Customers</a></li>';
$nav.='<li style="border-bottom:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/report.php?report=payments\',\'_blank\',\'760\',\'480\');"><a>Payments</a></li>';
$nav.='</ul>';
$nav.='</li>';
$nav.='<li><a>Admin</a>';
$nav.='<ul>';
$nav.='<li style="border-top:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'companies/editcompanies.php\',\'_blank\',\'340\',\'275\');"><a>Company</a></li>';
$nav.='<li OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'personnel/index.php\',\'_blank\',\'760\',\'480\');"><a>Personnel</a></li>';
$nav.='<li style="border-bottom:1px solid;" OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'config_editor.php\',\'_blank\',\'760\',\'480\');"><a>Preferences</a></li>';
//$nav.='<li OnClick="openwindow(\'admin/editgroups.php\',\'_blank\',\'760\',\'480\');"><a>Groups</a></li>';
//$nav.='<li style="border-bottom:1px solid;" OnClick="openwindow(\'admin/editconfig.php\',\'_blank\',\'760\',\'480\');"><a>Config</a></li>';
$nav.='<li style="border-bottom:1px solid;border-top:1px solid;"><a>Backup</a>';
$nav.='<ul>';
$nav.='<li style="border-bottom:1px solid;border-top:1px solid;" OnClick="if (confirm(\'This Process Requires LOCK TABLES.\nYou May Experience System Delay While Processing\n\nContinue With Backup?\')) { openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'admin/mysqldumptofile.php?nohtml=1\',\'_blank\',\'540\',\'260\'); }"><a>mysqldump to File</a></li>';
$nav.='</ul>';
$nav.='</li>';
$nav.='</ul>';
$nav.='</li>';
$nav.='<li OnClick="window.location=\''.$masterclass->mainconfig['dir'].'logout.php\'"><a>Logout</a></li>';
$nav.='</ul>';
$nav.='<br style="clear: left;" />';
$nav.='</div>';

echo $nav;
?>
<table width="100%" cellpadding="2" cellspacing="5" border="0">
<tr valign="top">
  <td width="30%">
<?php
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Due Today','');
  
  $unquieid='invoices_duelist_container';
  $updatelist_click='update_'.$unquieid.'();';

  $runcmdpre='';
  $cngpg_cmd="cngpg('display_invoicesdue','$unquieid',".$unquieid."_listview,document.getElementById('pagelist$unquieid').selectedIndex+1,'');";
  $runcmdpost=$cngpg_cmd;
  
  $listdata=$this->display_invoicesdue($unquieid,'',1);
  echo $masterclass->allclasses['websites']->disp_pages($runcmdpre,$runcmdpost,$unquieid,$listdata['load_listpage'],$listdata['load_listpagecnt']);
?>
<div id="<?php echo $unquieid; ?>"><?php echo $listdata['load_list']; ?></div>
<script language="javascript">
  var <?php echo $unquieid; ?>_listview='';
  function update_<?php echo $unquieid;?>() {
    <?php echo $cngpg_cmd; ?>
  }
</script>
<?php
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
echo $masterclass->allclasses['websites']->sitebox_vspacer();
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Overdue','');
  
  $unquieid='invoices_overduelist_container';
  $updatelist_click='update_'.$unquieid.'();';

  $runcmdpre='';
  $cngpg_cmd="cngpg('display_invoicesdue','$unquieid',".$unquieid."_listview,document.getElementById('pagelist$unquieid').selectedIndex+1,'');";
  $runcmdpost=$cngpg_cmd;
  
  $listdata=$this->display_invoicesdue($unquieid,'overdue',1);
  echo $masterclass->allclasses['websites']->disp_pages($runcmdpre,$runcmdpost,$unquieid,$listdata['load_listpage'],$listdata['load_listpagecnt']);
?>
<div id="<?php echo $unquieid; ?>"><?php echo $listdata['load_list']; ?></div>
<script language="javascript">
  var <?php echo $unquieid; ?>_listview='overdue';
  function update_<?php echo $unquieid;?>() {
    <?php echo $cngpg_cmd; ?>
  }
</script>
<?php

  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
echo $masterclass->allclasses['websites']->sitebox_vspacer();
?>
  </td><td width="70%">
<?php
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Customers','');

  $unquieid='customerslist_container';
  $customerslist_click='update_'.$unquieid.'();';
  
  $runcmdpre='';
  $cngpg_cmd="cngpg('display_customerlist','$unquieid',".$unquieid."_listview,document.getElementById('pagelist$unquieid').selectedIndex+1,'');";
  $runcmdpost=$cngpg_cmd;

  $nav='';
  $nav.='<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr valign="middle" class="sitebox_navigation">';
  $nav.='<td style="text-align:left;">';
  $nav.='<input type="button" class="button" value="New Customer" OnClick="openwindow(\''.$masterclass->mainconfig['htmldirectory'].'invoices/customers_invoice.php\',\'_blank\',\'760\',\'480\');">&nbsp;&nbsp;';
  $nav.='<input type="button" class="button" value="Refresh List" OnClick="customer_listview=\'all\';'.$customerslist_click.'">&nbsp;&nbsp;';
  $nav.='</td>';
  $nav.='</tr></table>';
  /* echo $masterclass->allclasses['websites']->sitebox_navigation($nav); */
  
  $customersdata=$this->display_customerlist($unquieid,'',1);
  echo $masterclass->allclasses['websites']->disp_pages($runcmdpre,$runcmdpost,$unquieid,$customersdata['load_listpage'],$customersdata['load_listpagecnt']);
?>
<div id="<?php echo $unquieid; ?>"><?php echo $customersdata['load_list']; ?></div>
<script language="javascript">
  var <?php echo $unquieid;?>_listview='';
  function update_<?php echo $unquieid;?>() {
    <?php echo $cngpg_cmd; ?>
  }
</script>
<?php

  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
echo $masterclass->allclasses['websites']->sitebox_vspacer();
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Invoices','');

  $unquieid='invoices_invoicelist_container';
  $invoiceslist_click='update_'.$unquieid.'();';

  $runcmdpre='';
  $cngpg_cmd="cngpg('display_invoices','$unquieid',".$unquieid."_listview,document.getElementById('pagelist$unquieid').selectedIndex+1,'');";
  $runcmdpost=$cngpg_cmd;

  $invoicelistdata=$this->display_invoices($unquieid,'',1);
  echo $masterclass->allclasses['websites']->disp_pages($runcmdpre,$runcmdpost,$unquieid,$invoicelistdata['load_listpage'],$invoicelistdata['load_listpagecnt']);
?>
<div id="<?php echo $unquieid; ?>"><?php echo $invoicelistdata['load_list']; ?></div>
<script language="javascript">
  var <?php echo $unquieid;?>_listview='';
  function update_<?php echo $unquieid;?>() {
    <?php echo $cngpg_cmd; ?>
  }
</script>
<?php
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
?>
</td></tr></table>
<?php

  return;
  }
}
?>
